namespace DICOM_PROJECT.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class install_database : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.UserProfile",
                c => new
                    {
                        UserProfileID = c.Int(nullable: false, identity: true),
                        Password = c.String(),
                        SocialID = c.String(),
                        Name = c.String(),
                        Birthday = c.DateTime(nullable: false),
                        Male = c.Boolean(nullable: false),
                        Address = c.String(),
                        Phone = c.String(),
                        UserType = c.String(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.UserProfileID);
            
            CreateTable(
                "dbo.Visit",
                c => new
                    {
                        VisitID = c.Int(nullable: false, identity: true),
                        PatientID = c.Int(nullable: false),
                        CreateDoctorID = c.Int(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                        UpdateDoctorID = c.Int(),
                        UpdateDate = c.DateTime(),
                        Symptom = c.String(),
                        Diagnosis = c.String(),
                        Treatment = c.String(),
                    })
                .PrimaryKey(t => t.VisitID)
                .ForeignKey("dbo.UserProfile", t => t.CreateDoctorID)
                .ForeignKey("dbo.UserProfile", t => t.PatientID)
                .ForeignKey("dbo.UserProfile", t => t.UpdateDoctorID)
                .Index(t => t.PatientID)
                .Index(t => t.CreateDoctorID)
                .Index(t => t.UpdateDoctorID);
            
            CreateTable(
                "dbo.Indication",
                c => new
                    {
                        IndicationID = c.Int(nullable: false, identity: true),
                        PatientID = c.Int(nullable: false),
                        DoctorID = c.Int(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                        RadiologistID = c.Int(),
                        UpdateDate = c.DateTime(),
                        IndicationInformation = c.String(),
                        IndicationResult = c.String(),
                        ImageVisitID = c.String(),
                        ImageID = c.Int(),
                    })
                .PrimaryKey(t => t.IndicationID)
                .ForeignKey("dbo.UserProfile", t => t.DoctorID)
                .ForeignKey("dbo.UserProfile", t => t.PatientID)
                .ForeignKey("dbo.UserProfile", t => t.RadiologistID)
                .Index(t => t.PatientID)
                .Index(t => t.DoctorID)
                .Index(t => t.RadiologistID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Visit", "UpdateDoctorID", "dbo.UserProfile");
            DropForeignKey("dbo.Visit", "PatientID", "dbo.UserProfile");
            DropForeignKey("dbo.Indication", "RadiologistID", "dbo.UserProfile");
            DropForeignKey("dbo.Indication", "PatientID", "dbo.UserProfile");
            DropForeignKey("dbo.Indication", "DoctorID", "dbo.UserProfile");
            DropForeignKey("dbo.Visit", "CreateDoctorID", "dbo.UserProfile");
            DropIndex("dbo.Indication", new[] { "RadiologistID" });
            DropIndex("dbo.Indication", new[] { "DoctorID" });
            DropIndex("dbo.Indication", new[] { "PatientID" });
            DropIndex("dbo.Visit", new[] { "UpdateDoctorID" });
            DropIndex("dbo.Visit", new[] { "CreateDoctorID" });
            DropIndex("dbo.Visit", new[] { "PatientID" });
            DropTable("dbo.Indication");
            DropTable("dbo.Visit");
            DropTable("dbo.UserProfile");
        }
    }
}
